﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Worldme.YHChatSDK.Common.Constant;

namespace Worldme.YHChatSDK.Common.Vo
{
    public class Result
    {
        public int Code { get; set; }
        public bool Success { get; set; }
        public string Message { get; set; }
        public object Data { get; set; }
        public long Timestamp { get; set; } = DateTimeOffset.Now.ToUnixTimeMilliseconds();

        public static Result Ok()
        {
            Result result = new Result();
            result.Code = (int)HttpStatusCode.OK;
            result.Message = CommonConstant.MSG_200;
            result.Success = true;
            return result;
        }

        public static Result Ok(object data)
        {
            Result result = new Result();
            result.Code = (int)HttpStatusCode.OK;
            result.Message = CommonConstant.MSG_200;
            result.Success = true;
            result.Data = data;
            return result;
        }

        public static Result Ok(string msg, object data)
        {
            Result result = new Result();
            result.Code = (int)HttpStatusCode.OK;
            result.Message = msg;
            result.Success = true;
            result.Data = data;
            return result;
        }

        public static Result Error()
        {
            Result result = new Result();
            result.Code = (int)HttpStatusCode.InternalServerError;
            result.Message = CommonConstant.MSG_500;
            result.Success = false;
            return result;
        }

        public static Result Error(int code, string msg)
        {
            Result result = new Result();
            result.Code = code;
            result.Message = msg;
            result.Success = false;
            return result;
        }

        public static Result Error(string msg)
        {
            Result result = new Result();
            result.Code = (int)HttpStatusCode.InternalServerError;
            result.Message = msg;
            result.Success = false;
            return result;
        }

        public static Result Error(string msg, object data)
        {
            Result result = new Result();
            result.Code = (int)HttpStatusCode.InternalServerError;
            result.Message = msg;
            result.Success = false;
            result.Data = data;
            return result;
        }
    }
}
